home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / tutorials / geometer / parse.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  5.9 KB  |  199 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. #include <stdio.h>
  19. #define PI 3.14159265358979323
  20.  
  21. enum tokentype {
  22.     Open, Close, Reserved, Identifier, Integer, Float, Str, Eof, Error,
  23.     Semicolon, Comma, Equal, Comment, OpenCurly, CloseCurly, 
  24. };
  25.  
  26. enum reservedword {
  27.     _geometry,
  28.     
  29.     _vertex, _line, _circle, 
  30.     _bezier, _length,
  31.     _vertpath, _animation, _conic, 
  32.     _angle, _ratio, 
  33.  
  34.     _ray12, _longline, _segment, 
  35.     
  36.     _diamond, _plus, _cross, _nomark, _soliddiamond,
  37.  
  38.     // colors:
  39.  
  40.     _black, _red, _green, _blue, _yellow, _cyan, _magenta, _white, 
  41.     _invisible, _smear, _blink, 
  42.     _c0, _c1, _c2, _c3, _c4, _c5, _c6, _c7, _c8, _c9, _c10, _c11,
  43.     _c12, _c13, _c14, _c15, _c16, _c17, _c18, _c19, _c20, _c21,
  44.     _c22, _c23, _c24, _c25, _c26, _c27, _c28, _c29, _c30, _c31, 
  45.  
  46.     // layers:
  47.  
  48.     _l0, _l1, _l2, _l3, _l4, _l5, _l6, _l7, _l8, _l9, _l10, _l11,
  49.     _l12, _l13, _l14, _l15, _l16, _l17, _l18, _l19, _l20, _l21,
  50.     _l22, _l23, _l24, _l25, _l26, _l27, _l28, _l29, _l30, _l31, 
  51.  
  52.     _free, _vonl, _vonc, _v_ll, _v_vvmid, _v_lc, _v_cc,
  53.     _v_vvratio, _v_avv, _v_ccenter, _v_lvmirror, _vonconic, 
  54.     _v_vcinv, _v_lconic, 
  55.     
  56.     _l_vv, _l_vlperp, _l_vlpar, _l_vc, _l_ccext, _l_ccint,
  57.     _l_conicv, 
  58.     
  59.     _c_vv, _c_vvv, _c_lll, _c_vlen, _c_ccinv, _c_lcinv, 
  60.     
  61.     _bez_vvvv, 
  62.     
  63.     _ratio_vvv,
  64.  
  65.     _len_vv, _len_plus, _len_minus, _len_f, _len_times, _len_divide, 
  66.     
  67.     _a_vvv, 
  68.     
  69.     _conic_vvvvv, _conic_lllll, 
  70.     
  71.     _animate, _vpath, _text, _comment, 
  72.     
  73.     // parsing info:
  74.     
  75.     _float, _int2, _int4, _none, 
  76.     
  77.     // macro stuff:
  78.  
  79.     _macro, 
  80. };
  81.  
  82. #include "geom.h"
  83.  
  84. enum atomtype {
  85.     RESERVEDWORD, ATOM, INTEGER, FLOAT, STR, 
  86. };
  87.  
  88. struct symtableentry {
  89.     char            symbol[30];        // name in geom file
  90. //    char            name[30];        // display name
  91.     reservedword    value;
  92.     primitive        *p;
  93.     float           f;
  94.     long            i;
  95. };
  96.  
  97. extern char     texttoken[];
  98. extern float    floattoken;
  99. extern long    longtoken;
  100. extern long     restable, idtable;
  101. extern long     xsize, ysize, llx, lly;
  102. extern reservedword currentlinetype;
  103. extern long     showinvisible;
  104.  
  105. extern primitive *pselected;
  106. extern float    pbsize;
  107.  
  108. tokentype       gettoken(FILE *);
  109.  
  110. extern long newtable(long size);
  111. extern void cleartable(long tt);
  112. extern symtableentry *lookup(long tt, char *str);
  113. extern void removeentry(long tt, char *str);
  114. extern symtableentry *addentry(long tt, char *str, reservedword value);
  115. extern void inittables();
  116. void parseerror(char *, long);
  117. void parseerror(char *);
  118. void displaymessage(char *);
  119. vertex *hitvertex(float, float);
  120. void initialize();
  121. void initscreen();
  122. void drawgeom();
  123. void drawui();
  124. void recalcsizes();
  125. void clearplist();
  126. vertex *hitvertex(float, float);
  127. line *hitline(float, float);
  128. line *hitanotherline(float, float, primitive *);
  129. circle *hitcircle(float, float);
  130. circle *hitanothercircle(float, float, primitive *);
  131. void getpoint(float *, float *, long, long);
  132. vertex *makevertex(float, float);
  133. line *linevertvert(vertex *, vertex *);
  134. circle *circvertvert(vertex *, vertex *);
  135. vertex *vertlineline(line *, line *);
  136. void verttoline(vertex *, line *);
  137. void verttocirc(vertex *, circle *);
  138. line *linevertlineperp(vertex *, line *);
  139. line *linevertlinepar(vertex *, line *);
  140. void mainloop();
  141. void selectvertex(float, float);
  142. void addprimitive(primitive *);
  143. primitive *hitprimitive(float, float);
  144. vertex *vertvertvertmid(vertex *, vertex *);
  145. long readgeometry(char *);
  146. void checkconstraints();
  147. vertex *linecirctovert1(line *, circle *, float, float);
  148. line *vertcirctoline1(vertex *, circle *, float, float);
  149. void deleteprimitive(primitive *);
  150. line *circcirctolineext1(circle *, circle *, float, float);
  151. line *circcirctolineint1(circle *, circle *, float, float);
  152. vertex *circcirctovert1(circle *, circle *, float, float);
  153. vertex *circcirctovert2(circle *, circle *);
  154. circle *vvvtocircle(vertex *, vertex *, vertex *);
  155. conic *vvvvvtoconic(vertex *, vertex *, vertex *, vertex *, vertex *);
  156. long dumpPostScript(char *);
  157. void cleartable(long);
  158. void setpcolor(primitive *, long);
  159. void setlinetype(line *, reservedword);
  160. void initfakefile(char *);
  161. long parsefile(FILE *);
  162. void genname(primitive *);
  163. void inittables();
  164. void displaymessage(char *);
  165. void removeentry(long, char *);
  166. long readlispexpression(FILE *);
  167. long readlispfile(FILE *);
  168. long newtable(long);
  169. symtableentry *lookup(long, char *);
  170. symtableentry *addentry(long,  char *, reservedword);
  171. tokentype gettoken(FILE *);
  172. void parseerror(char *, long);
  173. long printall(char *s);
  174. void vertonlineline(vertex *, line *, line *);
  175. float vvdist(vertex *, vertex *);
  176. float vldist(vertex *, line *);
  177. void solvevlc(line *, circle *, vertex *, long);
  178. void homogenizeline(line *);
  179. void line_vertcircletan(line *);
  180. void line_circcircleint(line *);
  181. void line_circcircleext(line *);
  182. void vert_circcircle(vertex *);
  183. void vert_lineconic(vertex *);
  184. void circle_lll(circle *);
  185. void circle_vvv(circle *);
  186. void circle_ccinvert(circle *);
  187. void v_vcinvert(vertex *);
  188. void circle_linecinvert(circle *);
  189. void vlvmirror(vertex *);
  190. void conic_vvvvv(conic *);
  191. void projecttoconic(vertex *, conic *);
  192. void ratio_vvv(length *);
  193. void v_vvratio(vertex *);
  194. void a_vvv(length *);
  195. void v_avv(vertex *);
  196. void a_atrisect(length *);
  197. void conic_lllll(conic *);
  198. void linetangenttoconic(line *);
  199.